﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMTC.Dao.BaseInfo;
using SMTC.Model.Model;

namespace SMTC.BO.BaseInfo
{
    public class ProductionUnitQueryServices
    {
        ProductionUnitQueryDao dao;
        public ProductionUnitQueryServices()
        {
            dao = new ProductionUnitQueryDao();
        }

        public List<SMT_ProductionUnitModel> GetProductionUnit(Query_PUModel _Query_PUModel)
        {

            _Query_PUModel.MaintenanceStartTime = string.IsNullOrEmpty(_Query_PUModel.MaintenanceStartTime) ? "1900-01-01" : _Query_PUModel.MaintenanceStartTime;
            _Query_PUModel.MaintenanceEndTime = string.IsNullOrEmpty(_Query_PUModel.MaintenanceEndTime) ? "9999-01-01" : _Query_PUModel.MaintenanceEndTime;

            _Query_PUModel.EffectiveTimeStart = string.IsNullOrEmpty(_Query_PUModel.EffectiveTimeStart) ? "1900-01-01" : _Query_PUModel.EffectiveTimeStart;
            _Query_PUModel.EffectiveTimeEnd = string.IsNullOrEmpty(_Query_PUModel.EffectiveTimeEnd) ? "9999-01-01" : _Query_PUModel.EffectiveTimeEnd;

            _Query_PUModel.Type = string.IsNullOrEmpty(_Query_PUModel.Type) ? "%" :"%"+ _Query_PUModel.Type+"%";
            _Query_PUModel.Abilty = string.IsNullOrEmpty(_Query_PUModel.Abilty) ? "%" : "%" + _Query_PUModel.Abilty + "%";
            _Query_PUModel.ModifyPer = string.IsNullOrEmpty(_Query_PUModel.ModifyPer) ? "%" : "%" + _Query_PUModel.ModifyPer + "%";

            return dao.GetProductionUnit(_Query_PUModel);
        }

        public List<SMT_ProductionUnitModel> GetProductionUnitForSelect(Query_PUModel _Query_PUModel)
        {

            _Query_PUModel.MaintenanceStartTime = string.IsNullOrEmpty(_Query_PUModel.MaintenanceStartTime) ? "1900-01-01" : _Query_PUModel.MaintenanceStartTime;
            _Query_PUModel.MaintenanceEndTime = string.IsNullOrEmpty(_Query_PUModel.MaintenanceEndTime) ? "9999-01-01" : _Query_PUModel.MaintenanceEndTime;

            _Query_PUModel.EffectiveTimeStart = string.IsNullOrEmpty(_Query_PUModel.EffectiveTimeStart) ? "1900-01-01" : _Query_PUModel.EffectiveTimeStart;
            _Query_PUModel.EffectiveTimeEnd = string.IsNullOrEmpty(_Query_PUModel.EffectiveTimeEnd) ? "9999-01-01" : _Query_PUModel.EffectiveTimeEnd;

            _Query_PUModel.Type = string.IsNullOrEmpty(_Query_PUModel.Type) ? "%" : "%" + _Query_PUModel.Type + "%";
            _Query_PUModel.Abilty = string.IsNullOrEmpty(_Query_PUModel.Abilty) ? "%" : "%" + _Query_PUModel.Abilty + "%";
            _Query_PUModel.ModifyPer = string.IsNullOrEmpty(_Query_PUModel.ModifyPer) ? "%" : "%" + _Query_PUModel.ModifyPer + "%";

            return dao.GetProductionUnitForSelect(_Query_PUModel);
        }
    }
}
